/*
 * @Descripttion: 
 * @version: 
 * @Author: TT
 * @Date: 2023-11-10 09:38:40
 * @LastEditors: TT
 * @LastEditTime: 2023-12-20 09:00:34
 */

import 'package:flutter/material.dart';
import 'package:hzy_normal_tool/hzy_normal_tool.dart';
import 'base_state.dart';
import '../common/app_router_observer.dart';

abstract class BaseStateRouterAware<T extends StatefulWidget>
    extends BaseStateV<T> with RouteAware {
  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    AppRouterObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    AppRouterObserver().routeObserver.unsubscribe(this);
    super.dispose();
  }

  @override
  void didPush() {
    super.didPush();
    viewWillAppear();
  }

  @override
  void didPop() {
    super.didPop();
    viewWillDisappear();
  }

  @override
  void didPopNext() {
    super.didPopNext();
    viewWillAppear();
  }

  @override
  void didPushNext() {
    super.didPushNext();
    viewWillDisappear();
  }

  viewWillAppear() {
    dPrint("界面将要出现");
  }

  viewWillDisappear() {
    dPrint("界面将要消失");
  }
}
